package ru.javadevelop.vegetarian.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.LinearLayout;
import ru.javadevelop.vegetarian.R;
import ru.javadevelop.vegetarian.common.ExtApplication;
import ru.javadevelop.vegetarian.common.interfaces.IActivity;
import ru.javadevelop.vegetarian.controls.HeaderTitles;
import ru.javadevelop.vegetarian.fragments.HeaderFragment;
import ru.javadevelop.vegetarian.fragments.RecipesFragment;
import ru.javadevelop.vegetarian.model.Recipe;


public class RecipesInCatActivity extends Activity implements IActivity {
    private  LinearLayout root;
    private HeaderFragment header_fragment;
    //******************************************************************************************************************
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_favorites);
        findControls();
        fillControls();
        setListeners();
    }
    //******************************************************************************************************************
    @Override
    public void findControls() {
        root = (LinearLayout)findViewById(R.id.root);
        header_fragment = (HeaderFragment)getFragmentManager().findFragmentById(R.id.header_fragment);
    }
    //******************************************************************************************************************
    @Override
    public void fillControls() {
        if (ExtApplication.Session.category==null)
            return;
        HeaderTitles headerTitles = new HeaderTitles(
                new Intent(this, HomeActivity.class),
                getString(R.string.main),
                ExtApplication.Session.category.name
        );
        header_fragment.setHeaderTitles(headerTitles);
        RecipesFragment recipesFragment = new RecipesFragment(Recipe.getByCategory(ExtApplication.Session.category.id));
        recipesFragment.setArguments(getIntent().getExtras());
        getFragmentManager().beginTransaction().add(R.id.root, recipesFragment).commit();
    }
    //******************************************************************************************************************
    @Override
    public void setListeners() {
        //To change body of implemented methods use File | Settings | File Templates.
    }
    //******************************************************************************************************************
    //******************************************************************************************************************
    //******************************************************************************************************************
    //******************************************************************************************************************
    //******************************************************************************************************************
    //******************************************************************************************************************
}
